
using QdbUnit;
using QdbUnit.Extensions;
using QdbUnit.Extensions.Tests;
using QdbUnit.Mocking;
using Qdb.Config;
using Qdb.Foundation;

namespace QdbUnit.Extensions.Tests
{
	public class SimpleQdbTestCase : AbstractQdbTestCase
	{
		public static readonly DynamicVariable RecorderVariable = DynamicVariable.NewInstance
			();

		public class Data
		{
		}

		protected override void Configure(IConfiguration config)
		{
			Record(new MethodCall("fixture", new object[] { Fixture() }));
			Record(new MethodCall("configure", new object[] { config }));
		}

		private void Record(MethodCall call)
		{
			Recorder().Record(call);
		}

		private MethodCallRecorder Recorder()
		{
			return ((MethodCallRecorder)RecorderVariable.Value);
		}

		protected override void Store()
		{
			Record(new MethodCall("store", new object[] {  }));
			Fixture().Db().Store(new SimpleQdbTestCase.Data());
		}

		public virtual void TestResultSize()
		{
			Record(new MethodCall("testResultSize", new object[] {  }));
			Assert.AreEqual(1, Fixture().Db().QueryByExample(typeof(SimpleQdbTestCase.Data))
				.Count);
		}
	}
}
